<?php
include_once "../header1.php";
?>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","upp_sch_names.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{
document.form1.SchName.value=val;
document.getElementById("List").innerHTML="";
}
</script>
</head>
<body>
<?php

include_once '../Login/databaseconnection.php';

if(!loggedin())
{
	require_once '../index.php';
}
else
{ 
if(isset($_POST['SaveChanges']))
   {
 $Census_Number=$_POST['Census_Number'];
 if($_SESSION['Access_Type']=="Teacher in Charge")
{
$SchName=$_POST['SchName'];
$name=explode(",",$SchName);
$nam=$name[0];
$tn=count($name);
for($i=1;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$name[$i];
}
else
{
$adr=$adr.",".$name[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $Census_Number=$row['Census_Number'];
}
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   $get_Cen=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
   if($rowcen= mysql_fetch_array($get_Cen))
{
    $Own_Census_Number=$rowcen['Census_Number'];
    if($Census_Number==$Own_Census_Number)
	{
	$result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
if(mysql_num_rows($result)==0)
{
$_SESSION['errornorow']="Very sorry there is no result!";
}
else
{
  require_once 'UPP.php';
  }
   }
    else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
   }
   }
   }
else if($_SESSION['Access_Type']=="Administrator")
{
$result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
if(mysql_num_rows($result)==0)
{
$_SESSION['errornorow']="Very sorry there is no result!";
}
else
{
require_once 'UPP.php';
}
}   
   else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
   }
 $Census_Number="";
if(isset($_POST['Edit_this']))
{
$SchName=$_POST['SchName'];
$name=explode(",",$SchName);
$nam=$name[0];
$tn=count($name);
for($i=1;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$name[$i];
}
else
{
$adr=$adr.",".$name[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $Census_Number=$row['Census_Number'];
}
$_SESSION['Census_Number']=$Census_Number;
if($_SESSION['Access_Type']=="Teacher in Charge")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   if($Census_Number=="")
	   {
	 $_SESSION['errornorow']="Please select the School's name!";
	   }
	  if($Census_Number!="")
	   {
	   $get_Cen=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
  if($rowcen= mysql_fetch_array($get_Cen))
{
    $Own_Census_Number=$rowcen['Census_Number'];
    if($Census_Number==$Own_Census_Number)
	{
	    $result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
	   if(mysql_num_rows($result)==0)
   {
   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   }
   else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
   }
    else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
 }
}
 else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
}
else if($_SESSION['Access_Type']=="Administrator")
{
if($Census_Number=="")
	   {	   
$_SESSION['errornorow']="Please select the School's name!";
	   }
	   if($Census_Number!="")
	   {
	    $result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
	   if(mysql_num_rows($result)==0)
   {
	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   }
	   }
	   else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
	}
?><?php
include_once "../header2.php";
?><?php
include_once "topmenu.php";
?>
 <div id="content">
	<div id="main">
	  <div id="bodyfield">
 <div id="lefttablereg"><form action="#" method="POST" name="form1"> <table width="1000" border="0" class="tablefontv">
  <tr>
    <td height="18" colspan="10" align="left" scope="row" class="err">
   <?php
    if(isset($_POST['Edit_this'])||isset($_POST['SaveChanges']))
{
if(isset($_SESSION['errornotallo']))
{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errornotallo'];
unset($_SESSION['errornotallo']);
}
		if(isset($_SESSION['errornorow']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}

	if(isset($_SESSION['errorin']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
		
	}
	if(isset($_SESSION['errornotallo']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornotallo'];
		unset($_SESSION['errornotallo']);
	}
	if(isset($_SESSION['errorempt']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo '<br/>'.$_SESSION['errorempt'];
		unset($_SESSION['errorempt']);
	}
}
?></td>
    <td colspan="4">&nbsp;</td>
  </tr>
  </table>
  <table width="542" border="0" class="tablefontv">
 
         
          <tr>
            <th width="46" rowspan="2" align="left" scope="row" bgcolor="#6AB5FF">&nbsp;</th>
            <th width="192" height="22" align="left" scope="row" bgcolor="#6AB5FF">School's Name</th>
            <th width="10" align="left" scope="row" bgcolor="#6AB5FF">:-</th>
            <td width="177" bgcolor="#999999">
			<?php
	 	if($_SESSION['Access_Type']=="Teacher in Charge")
{
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id']; 
    $snam=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
}
	 echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' size='40' readonly='readonly'/>";
}
	else if($_SESSION['Access_Type']=="Administrator")
{
	if(!isset($SchName))
	{
		$snam=mysql_query("SELECT * FROM school WHERE School_Id='$School_Id'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
	}
	    echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' size='40'/>";
}
	  ?></td>
            <td width="95" bgcolor="#6AB5FF">&nbsp;</td>
          </tr>
          <tr>
            <th height="20" align="left" bgcolor="#6AB5FF" scope="row"><a href="UpdateSch.php" class="reset">Reset |</a>
            <input name="Edit_this" dir="right" align="middle" type="submit" value="Edit this" class="buttonok"/></th>
            <td height="20" align="left" bgcolor="#6AB5FF" scope="row"></td>
            <td height="20" align="left" bgcolor="#6AB5FF" scope="row">&nbsp;</td>
            <td height="20" align="left" bgcolor="#6AB5FF" scope="row">&nbsp;</td>
          </tr>
  </table>
</form>
<form action="#" method="POST">
<?php
if(isset($_POST['Edit_this']))
{
if($Census_Number!="")
{
if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Administrator")
{
if($_SESSION['Access_Type']=="Teacher in Charge")
{
$School_Id=$_POST['School_Id'];
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   $get_Cen=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
   while($rowcen= mysql_fetch_array($get_Cen))
{
   $Own_Census_Number=$rowcen['Census_Number'];
   }}
   }
    if(($_SESSION['Access_Type']=="Teacher in Charge"&&$Census_Number==$Own_Census_Number)||$_SESSION['Access_Type']=="Administrator")
	{
	$result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
 if(mysql_num_rows($result)>0)
  {
		echo '</br><table width="1300" height="400" border="0" class="tablefontv">';
 while($row=mysql_fetch_array($result))
  {
 $Congeniality=$row['Congeniality'];
 $Function=$row['Function'];
 $Ethinicity=$row['Ethinicity'];
 $Principal_Name=$row['Principal_Name'];
$School_Id=$row['School_Id'];
  $Zone=$row['Zone'];
  $Division=$row['Division'];
  $Province=$row['Province'];
  $District=$row['District'];
  $Census_Number=$row['Census_Number'];
  $Name=$row['Name'];
  $Status=$row['Status'];
  $Type=$row['Type'];
  $Grade_Range=$row['Grade_Range'];
  $Medium=$row['Medium'];
  $Female_Students=$row['Female_Students'];
  $Male_Students=$row['Male_Students'];
  $Tp_Number=$row['Tp_Number'];
  $Fax_Number=$row['Fax_Number'];
  $E_Mail=$row['E_Mail'];
  $Web_Address=$row['Web_Address'];
  $Special_Projects=$row['Special_Projects'];
  for($i=0;$i<count($Special_Projects);$i++)
  {
	 $S_Pro+=$Special_Projects[$i];
  }
  $Address=$row['Address'];
  $Account_Number=$row['Account_Number'];
  
   ?>
		<?php
	
   echo '<tr>';
      echo '<td width="73" height="24" scope="row" align="left">';
echo "School ID";
      echo '</td>';
      echo '<td width="8" scope="row" align="left"height="09">';
	  echo ':-';
	  echo '</td>';
	  echo '<td width="142" height="24">';
	  if($_SESSION['Access_Type']=="Teacher in Charge")
	  {
	  echo "<input type='text' name='School_Id' value='$School_Id' readonly='readonly'/>";
	  }
	  else if($_SESSION['Access_Type']=="Administrator")
	  {
	  echo "<input type='text' name='School_Id' value='$School_Id'/>";
	  }
	echo '</td>';
	  echo '<td height="24" scope="row" align="left">';
	  echo "School Name";
      echo '</td>';
      echo '<td scope="row" align="left">';
	  echo ':-';
	  echo '</td>';
     echo '<td>';
	 echo "<input type='text' name='Name' value='$Name'/>";
	 echo '</td>';
	echo '<td height="29" align="left" scope="row">';
	  echo "School Address";
      echo '</td>';
      echo '<td scope="row">';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	 echo   "<input type='text' name='Address' value='$Address' size='30'/>";
	  echo '</td>';
	  echo '<td colspan="2"></td>';
	 echo '</tr>';
	echo '<tr>';
    echo '<td height="24" align="left" scope="row">';
	echo "Census Number";
	echo '</td>';
    echo '<td scope="row">';
	echo ':-';
	echo '</td>';
    echo '<td>';
	if($_SESSION['Access_Type']=="Teacher in Charge")
	  {
	 echo "<input type='text' name='Census_Number' value='$Census_Number' readonly='readonly'/>";
	  }
	  else if($_SESSION['Access_Type']=="Administrator")
	  {
	echo "<input type='text' name='Census_Number' value='$Census_Number'/>";
	}
	echo '</td>';
	echo '<td height="24" align="left" scope="row">';
	echo "Principal Name";
	echo '</td>';
    echo '<td scope="row">';
	echo ':-';
	echo '</td>';
    echo '<td>';
	echo "<input type='text' name='Principal_Name' value='$Principal_Name'/>";
	echo '</td>';
	echo '<td height="24" align="left" scope="row">';
	echo "Congeniality";
	echo '</td>';
    echo '<td scope="row">';
	echo ':-';
	echo '</td>';
    echo '<td><select name="Congeniality" id="Congeniality">';
		 if(isset($Congeniality))
	  {
	 echo '<option value="'.$Congeniality.'">'.$Congeniality.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	$con=mysql_query("SELECT DISTINCT(Congeniality) FROM school");	  
  while($row=mysql_fetch_array($con))
  {
	 $Cong=$row['Congeniality'];
if($Cong!=$Congeniality)
{
	  echo '<option value="'.$Cong.'">'.$Cong.'</option>';
}
  }
  echo '</select></br>
  <label><font color="red">or</font> New congeniality:&nbsp;&nbsp;&nbsp;</label>';	 
	  if($New_Congeniality!="")
	  {
	  echo "<input type='text' name='New_Congeniality' value='$New_Congeniality'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Congeniality'/>";
	  }
	  echo '</td>';	
    echo '<td>';
	echo '</td>';		
    echo '<td>';
	echo '</td>';
    echo '</tr>';
	echo '<tr>';
	 echo '<td>';
	  echo "Grade Range";
	echo '</td>';
      echo '<td>';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  if($Grade_Range=="1-5")
	  {
        echo '<input type="radio" name="Grade_Range" value="1-5" id="Grade_Range_0" checked="checked" />';
        echo "1-5";
	  }
	  else
	  {
		  echo '<input type="radio" name="Grade_Range" value="1-5" id="Grade_Range_0" />';
        echo "1-5";
	  }
	   echo '<br />';
	  if($Grade_Range=="1-11")
	  {
       
        echo '<input type="radio" name="Grade_Range" value="1-11" id="Grade_Range_3" checked="checked" />';
          echo "1-11";
		  }
	  else
	  {
		  echo '<input type="radio" name="Grade_Range" value="1-11" id="Grade_Range_3" />';
          echo "1-11";
	  }
        echo '<br />';
		if($Grade_Range=="1-13")
		{
       echo '<input type="radio" name="Grade_Range" value="1-13" id="Grade_Range_4" checked="checked" />';
          echo "1-13";
        }
	  else
	  {
		   echo '<input type="radio" name="Grade_Range" value="1-13" id="Grade_Range_4" />';
          echo "1-13";
	  }
        echo '<br />';
       
       if($Grade_Range=="6-11")
	   {   echo '<input type="radio" name="Grade_Range" value="6-11" id="Grade_Range_1" checked="checked" />';
          echo "6-11";
		  }
	  else
	  {
		  echo '<input type="radio" name="Grade_Range" value="6-11" id="Grade_Range_1" />';
          echo "6-11";
	  }
		 echo '<br />';
       if($Grade_Range=="6-13")
	   {
          echo '<input type="radio" name="Grade_Range" value="6-13" id="Grade_Range_2" checked="checked" />';
          echo "6-13";
		  }
	  else
	  {
		  echo '<input type="radio" name="Grade_Range" value="6-13" id="Grade_Range_2" />';
          echo "6-13";
	  }
		echo '<br />';
		if($Grade_Range=="Others")
		{
        echo '<input type="radio" name="Grade_Range" value="Others" id="Grade_Range_5" checked="checked" />';
          echo "Others";
		}
	  else
	  {
		  echo '<input type="radio" name="Grade_Range" value="Others" id="Grade_Range_5" />';
          echo "Others";
	  }
		  echo '</td>';
		 echo '<td>';
	  echo "Medium";
	  echo '</td>';
      echo '<td>';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  if($Medium =="Tamil")
	  {
        echo '<input type="radio" name="Medium" value="Tamil" id="Medium_0" checked="checked" />';
       echo "Tamil";
	   }else
	   {
		   echo '<input type="radio" name="Medium" value="Tamil" id="Medium_0" />';
       echo "Tamil";
	   }
        echo '<br />';
		if($Medium=="English")
	  {
        echo '<input type="radio" name="Medium" value="English" id="Medium_1" checked="checked" />';
          echo "English";
	  }else
	  {
		  echo '<input type="radio" name="Medium" value="English" id="Medium_1" />';
          echo "English";
	  }
        echo '<br />';
		if($Medium=="Mix(Tamil & English)")
	  {
        echo '<input type="radio" name="Medium" value="Mix(Tamil &amp; English)" id="Medium_2" checked="checked" />';
          echo "Mix(Tamil &amp; English)";
	  }
		  else
		  {
			  echo '<input type="radio" name="Medium" value="Mix(Tamil &amp; English)" id="Medium_2" />';
          echo "Mix(Tamil &amp; English)";
		  }
        echo '<br />';
		if($Medium=="Sinhala")
	  {
        echo '<input type="radio" name="Medium" value="Sinhala" id="Medium_3" checked="checked" />';
          echo "Sinhala";
	  }else
	  {
		   echo '<input type="radio" name="Medium" value="Sinhala" id="Medium_3" />';
          echo "Sinhala";
	  }
        echo '<br />';
		if($Medium=="Mix(Tamil &amp; Sinhala)")
	  {
       echo '<input type="radio" name="Medium" value="Mix(Tamil &amp; Sinhala)" id="Medium_4" checked="checked" />';
          echo "Mix(Tamil &amp; Sinhala)";
	  }else
	  {
		  echo '<input type="radio" name="Medium" value="Mix(Tamil &amp; Sinhala)" id="Medium_4" />';
          echo "Mix(Tamil &amp; Sinhala)";
	  }
        echo '<br />';
		if($Medium=="Mix(Tamil,English &amp; Sinhala)")
	  {
        echo '<input type="radio" name="Medium" value="Mix(Tamil,English &amp; Sinhala)" id="Medium_5" checked="checked" />';
         echo "Mix(Tamil,English &amp; Sinhala)";
	  }else
	  {
		   echo '<input type="radio" name="Medium" value="Mix(Tamil,English &amp; Sinhala)" id="Medium_5" />';
         echo "Mix(Tamil,English &amp; Sinhala)";
	  }
		 echo '</td>';  
		  echo '<td width="56">';
	  echo "School Status";
	  echo '</td>';
	  echo '<td width="10" height="09">';
	  echo ':-';
	  echo '</td>';
	  echo '<td width="122">';
	  if($Status=="National")
	  {
	    echo '<input type="radio" name="Status" value="National" id="Status_0" checked="checked" />';
	   echo "National";
	  }
	  else
	  {
		  echo '<input type="radio" name="Status" value="National" id="Status_0" />';
	   echo "National";
	  }
        echo '<br />';
        if($Status=="Provincial")
		{
          echo '<input type="radio" name="Status" value="Provincial" id="Status_1" checked="checked" />';
          echo "Provincial";
  }
  else
  {
	   echo '<input type="radio" name="Status" value="Provincial" id="Status_1" />';
          echo "Provincial";
  }
  if($Status=="Private")
		{
          echo '<input type="radio" name="Status" value="Private" id="Status_2" checked="checked" />';
          echo "Private";
  }
  else
  {
	   echo '<input type="radio" name="Status" value="Private" id="Status_2" />';
          echo "Private";
  }
		  echo '</td>'; 
		  echo '<td colspan="2"></td>';
		  echo '</tr>';
		   echo '<tr>';
	  echo '<td width="79" height="24">';
	  echo "Telephone Number";
	  echo '</td>';
	  echo '<td width="8">';
	  echo ':-';
	  echo '</td>';
	  echo '<td width="177" height="24">';
	 echo "<input type='text' name='Tp_Number' value='$Tp_Number'/>";
	  echo '</td>';
	 	  echo '<td height="27" align="left" scope="row">'; 
	  echo "Division";
      echo '</td>';
      echo '<td scope="row">';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	 echo "<input type='text' name='Division' value='$Division'/>";
	  echo '</td>';
	  echo '<td height="24" align="left" scope="row">';
	   echo "Zone";
	   echo '</td>';
      echo '<td scope="row">';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  echo "<input type='text' name='Zone' value='$Zone'/>";
	  echo '</td>';
	  echo '<td colspan="2"></td>';
    echo '</tr>';
	  echo '<tr>';
	 echo '<td height="24" align="left" scope="row">';
	  echo "District";
      echo '</td>';
      echo '<td scope="row">';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  echo "<input type='text' name='District' value='$District'/>";
	  echo '</td>';
	  echo '<td>';
	 echo "School Type";
	 echo '</td>';
     echo '<td>';
	 echo ':-';
	 echo '</td>';
     echo '<td>';
	 if($Type=="1AB")
	 {
       echo '<input type="radio" name="Type" value="1AB" id="Type_0" checked="checked" />';
       echo "1AB";
	 }
      
	   else
	   {
		   echo '<input type="radio" name="Type" value="1AB" id="Type_0" />';
       echo "1AB";} 
	    echo '<br />';
        if($Type=="1C")
	 {
         echo '<input type="radio" name="Type" value="1C" id="Type_1" checked="checked" />';
         echo "1C";
	 }
	 else
	 {
		  echo '<input type="radio" name="Type" value="1C" id="Type_1" />';
         echo "1C";
	 }
       echo '<br />';
       
	     if($Type=="2")
	 {
         echo '<input type="radio" name="Type" value="2" id="Type_2" checked="checked" />';
         echo "2";
	 } else
	 {
		  echo '<input type="radio" name="Type" value="2" id="Type_2" />';
         echo "2";
	 }
       echo '<br />';
      if($Type=="3")
	  { 
         echo '<input type="radio" name="Type" value="3" id="Type_3" checked="checked" />';
         echo "3";
	  }
		  else
	 {
		 echo '<input type="radio" name="Type" value="3" id="Type_3" />';
         echo "3";
	 }
		 echo '</td>';
		 echo '<td height="24" align="left" scope="row">';
	  echo "Province";
	  echo '</td>';
      echo '<td scope="row">';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
    echo "<input type='text' name='Province' value='$Province'/>";
	  echo '</td>';
	  echo '<td colspan="2"></td>';
	  echo '</tr>';
	  echo '<tr>';
	echo '<td height="24" align="left" scope="row">';
	echo "Ethinicity";
	echo '</td>';
    echo '<td scope="row">';
	echo ':-';
	echo '</td>';
    echo '<td><select name="Ethinicity" id="Ethinicity">';
		 if(isset($Ethinicity))
	  {
	 echo '<option value="'.$Ethinicity.'">'.$Ethinicity.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  	  $eth=mysql_query("SELECT DISTINCT(Ethinicity) FROM school");
	  
  while($row=mysql_fetch_array($eth))
  {
	 $Ethni=$row['Ethinicity'];
if($Ethni!=$Ethinicity)
{
	  echo '<option value="'.$Ethni.'">'.$Ethni.'</option>';
}
  }
 echo '</select>
	  </br><label><font color="red">or</font> New ethinicity:&nbsp;&nbsp;&nbsp;</label>';
	  if($New_Ethinicity!="")
	  {
	  echo "<input type='text' name='New_Ethinicity' value='$New_Ethinicity'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Ethinicity'/>";
	  }	  
	  echo '</td>';	
    echo '<td>Functioning state';
	echo '</td>';
     echo '<td>:-';
	echo '</td>';
    echo '<td><select name="Function" id="Function">';
		 if(isset($Function))
	  {
	 echo '<option value="'.$Function.'">'.$Function.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  	  $func=mysql_query("SELECT DISTINCT(Function) FROM school");
	  
  while($row=mysql_fetch_array($func))
  {
	 $Fun=$row['Function'];
if($Fun!=$Function)
{
	  echo '<option value="'.$Fun.'">'.$Fun.'</option>';
}
  }
echo '</select></br><label><font color="red">or</font> New functioning state:&nbsp;&nbsp;&nbsp;</label>';
	  if($New_Function!="")
	  {
	  echo "<input type='text' name='New_Function' value='$New_Function'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Function'/>";
	  }
	  echo '</td>';	
    echo '<td>';
	echo '</td>';
    echo '<td>';
	echo '</td>';
      echo '<td scope="row">';
	  echo '</td>';
      echo '<td>';
   echo '</td>';
	  echo '<td colspan="2"></td>';
	  echo '</tr>';
	  echo '<tr>';
      echo '<th height="24" align="left" scope="row">';
	  echo "Number of Students";
	  echo '</th>';
      echo '<th scope="row">';
	  echo ':-';
	  echo '</th>';
      echo '<td colspan="6">';
	  echo "Male:";
       echo "<input type='text' name='Male_Students' value='$Male_Students'/>";
     echo "Female:";
         echo "<input type='text' name='Female_Students' value='$Female_Students'/>";
		echo '</td>';
       echo '<td>';
	  echo "Special projects";
       echo '</td>';
      echo '<td>';
	  echo ':-';
	  echo '</td>';
      echo '<td><div style="width:180px; height:220px; overflow-Y:scroll; ">';
	  $all_S_P=mysql_query("SELECT DISTINCT(Special_Projects) FROM school");
while($r_sp=mysql_fetch_array($all_S_P))
{
$sp_exists="";
$each_sp=explode(",",$r_sp['Special_Projects']);
$All_SProjects=explode(",",$All_Special_Projects);
for($spr=0;$spr<count($each_sp);$spr++)
{
if($each_sp[$spr]!="")
{
if($each_sp[$spr]!="")
{
if(substr($each_sp[$spr],0,6)=="other_")
{
$each_sp[$spr]=substr($each_sp[$spr],6);
}
if($each_sp[$spr]=="OLPC")
{
$OLPC="exists";
}
else if($each_sp[$spr]=="Interactive Whiteboard")
{
$Interactive_Whiteboard="exists";
}
else if($each_sp[$spr]=="Isuru")
{
$Isuru="exists";
}
else if($each_sp[$spr]=="Navodaya")
{
$Navodaya="exists";
}
else if($each_sp[$spr]=="E-village")
{
$E_village="exists";
}
else if($each_sp[$spr]=="1000 School Dev")
{
$Tho_School_Dev="exists";
}
else if($each_sp[$spr]=="Child friendly school")
{
$Child_friendly_school="exists";
}
for($s=0;$s<count($All_SProjects);$s++)
{
if($each_sp[$spr]==$All_SProjects[$s])
{
$sp_exists="yes";
break;
}
}
if($sp_exists!="yes")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects=$each_sp[$spr];
}
else
{
$All_Special_Projects=$All_Special_Projects.",".$each_sp[$spr];
}
}
}
}
}
}
if($OLPC!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="OLPC";
}
else
{
$All_Special_Projects=$All_Special_Projects.",OLPC";
}
  }
  if($Interactive_Whiteboard!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Interactive Whiteboard";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Interactive Whiteboard";
}
   }
   if($Isuru!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Isuru";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Isuru";
}
   }
     if($Navodaya!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Navodaya";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Navodaya";
}
   }
     if($E_village!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="E-village";
}
else
{
$All_Special_Projects=$All_Special_Projects.",E-village";
}
   }
     if($Tho_School_Dev!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="1000 School Dev";
}
else
{
$All_Special_Projects=$All_Special_Projects.",1000 School Dev";
}
   }
   if($Child_friendly_school!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Child friendly school";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Child friendly school";
}
}
$All_Spe_Projects=explode(",",$All_Special_Projects);
$other="";
if($Special_Projects!="")
{
$S_Proje= explode(",",$Special_Projects);
for($s=0;$s<count($All_Spe_Projects);$s++)
{
$S_Proj="";
for($i=0;$i<count($S_Proje);$i++)
{
if($S_Proje[$i]==$All_Spe_Projects[$s])
{
$S_Proj="yes";
}
}
if($S_Proj=="yes")
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]' checked='checked'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
  else if($S_Proj=="")
  {
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
else if(substr($All_Spe_Projects[$s],0,6)=="other_")
  {
  $other="exists";
    echo 'mm'.$sp=substr($All_Spe_Projects[$s],6);
	if($sp!="")
	{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)' checked='checked'/>";
echo "Others";
  echo '<br/>';
  }
  else
  {
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
  }
?>
<textarea name='Special_Projects_Others'><?php echo $sp." "; ?></textarea>
<?php
}
}
if($other!="exists")
{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
 ?>
<textarea name='Special_Projects_Others'></textarea>
<?php
}
}
else
{
for($sp=0;$sp<count($All_Spe_Projects);$sp++)
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$sp]'/>";
echo "$All_Spe_Projects[$sp]";
echo '<br/>';
}
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others:";
  echo '<br/>';
echo "<textarea name='Special_Projects_Others'></textarea>";
}
     echo '</div></td>';
      echo '<td>';
	  echo '</td>';
      echo '<td>';
	  echo '</td>';
	  echo '<td>';
	  echo '</td>';
	   echo '<td>';
	  echo '</td>';
      echo '<td colspan="3">';
	   echo '<input name="SaveChanges" align="middle" type="submit" value="Save changes" class="buttonok_save"/>';
	  echo '</td>';
    echo '</tr>';
	  echo '<tr>';
	 echo '<td height="24">';
	  echo "Web Address";
	  echo '</td>';
      echo '<td>';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  echo "<input type='text' name='Web_Address' value='$Web_Address'/>";
	  echo '</td>';
	  echo '<td height="24">';
	 echo "Fax Number";
	 echo '</td>';
     echo '<td>';
	 echo ':-';
	 echo '</td>';
     echo '<td>';
	 echo "<input type='text' name='Fax_Number' value='$Fax_Number'/>";
	 echo '</td>';
	  echo '<td height="24">';
	  echo "Email Address";
	  echo '</td>';
      echo '<td>';
	  echo ':-';
	  echo '</td>';
      echo '<td>';
	  echo "<input type='text' name='E_Mail' value='$E_Mail' size='30'/>";
	  echo '</td>';
	  echo '<td colspan="2"></td>';
	   echo '</tr>';
	 echo '<tr>';echo '<td width="55">';
	  	  echo "Account Number";
	   echo '</td>';
	  echo '<td width="10">';
	  echo ":-";
	  echo '</td>';
	  echo '<td width="411">';
	 echo "<input type='text' name='Account_Number' value='$Account_Number'/>";
	  echo '</td>';
	  echo '<td colspan="8"></td>';
    echo '</tr>';
	}
 echo '</table>';
}
}
  }
 }
 }
?>
 </form>
  </div>
 <div id="righttablereg">
  <div class="suggestionListsch" id="List"></div>
 </div>
  </div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">SCHOOLS</h2>
            </div>
  <?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
?>
<?php
}
?>
</body>
</html>